<template>
  <div>
    <!-- 面包屑 -->
    <MBX level1="权限管理" level2="权限列表"></MBX>

    <!-- 卡片 -->
    <!-- 主体区域 -->
    <el-card class="mt16">
      <el-table border :data="rightsData" style="width: 100%">
        <el-table-column label="#" type="index"></el-table-column>
        <el-table-column label="权限名称" prop="authName"></el-table-column>
        <el-table-column label="路径" prop="path"></el-table-column>
        <el-table-column label="权限等级" prop="level">
          <template slot-scope="scope">
            <div>
              <!-- 过滤器 -->
              <el-tag :type="typeObj[scope.row.level]">{{
                scope.row.level | rank
              }}</el-tag>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { rightsListApi } from "../../../http/api";
export default {
  data() {
    return {
      rightsData: [], //列表数据
      // 等级颜色
      typeObj: {
        0: "primary",
        1: "success",
        2: "warning",
        3: "info",
      },
    };
  },
  methods: {
    // 请求所有权限列表数据
    async rightsList() {
      const res = await rightsListApi();

      this.rightsData = res;
      // console.log("所有权限列表数据:", this.rightsData);
    },
  },
  created() {
    this.rightsList();
  },
};
</script>

<style lang="scss" scoped></style>
